//
//  SQLBaseTable.m
//  SQL面向对象数据库封装
//
//  Created by 崔博 on 2018/9/25.
//  Copyright © 2018年 崔博. All rights reserved.
//

#import "SQLBaseTable.h"
#import "SQLCommandHandle.h"
#import "SQLCommandHandle+creatTable.h"
@implementation SQLBaseTable

/**
 创建db和表
 */
- (instancetype)init
{
    self = [super init];
    if (self) {
        
        // 判断子类是否实现协议
        if ([self conformsToProtocol:@protocol(SQLBaseTableProtocol)]) {
            id <SQLBaseTableProtocol> delegate = (id <SQLBaseTableProtocol>) self;
            // 1 创建一个sql对象
            SQLCommandHandle * handle = [[SQLCommandHandle alloc] init];
            handle.dataBaseName = [delegate dataFileName];
            // 2 准备sql语句 对sqlcommand操作
            [handle preSqlCreateTabelName:[delegate tableName] column:[delegate colomnValue]];
            // 3 执行语句
            [handle sqlExcuteReadCommand];
            // 4 操作123，我们把创建db放倒 当做sqlhandle一个属性
        }else
        {
            [NSException exceptionWithName:@"" reason:@"" userInfo:@{}];
        }
    }
    return self;
}
@end
